home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / connectWindow.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  49.4 KB  |  1,742 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  12 July 1996
  22. //  Author:         spam
  23. //
  24. //  Description:
  25. //      This file implements the connectWindow for making connections between nodes.
  26. //
  27. //////////////////////////////////////////////////////////////////////
  28. //
  29. //  Procedure Name:
  30. //      connectWinModalCmd
  31. //
  32. //  Description:
  33. //      conifugres the window to either me modal (ie, do a bunch of things,
  34. //        then press a button to perform the actions) or interactive, where
  35. //        connections are made/broken for each click in the input window.
  36. //        
  37. //  Input Arguments:
  38. //      $topWindow - name of the top connection window for control name construction
  39. //
  40. //  Return Value:
  41. //      None.
  42. //
  43. global proc connectWinModalCmd(string $topWindow)
  44. {
  45.     global string $rightWin, $leftWin;
  46.  
  47.     int $autoConnect = `optionVar -q "connectWindowAutoConnect"`;
  48.     int $isModal = 0;
  49.  
  50.     if($autoConnect == 0) {
  51.         $isModal = 1;
  52.     }
  53.  
  54.     string $buttonParent = $topWindow + "|tl|cwForm|";
  55.  
  56.     string $dis = $buttonParent + "dis";
  57.     string $con = $buttonParent + "con";
  58.  
  59.     button -e -enable $isModal $dis;
  60.     button -e -enable $isModal $con;
  61.  
  62.     int $leftToRight = 1;
  63.                     
  64.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  65.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  66.     } else {
  67.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  68.     }
  69.  
  70.     if($autoConnect) {
  71.         // we've just turned off autoconnect; set input window
  72.         // to highlight unconnected pressed plugs.
  73.         if($leftToRight) {
  74.             nodeOutliner -e -pressHighlightsUnconnected false $rightWin;
  75.         } else {
  76.             nodeOutliner -e -pressHighlightsUnconnected false $leftWin;
  77.         }
  78.     } else {
  79.         // we've just turned on autoconnect; set input window
  80.         // to not highlight unconnected pressed plugs.
  81.         nodeOutliner -e -pressHighlightsUnconnected true $rightWin;
  82.         nodeOutliner -e -pressHighlightsUnconnected true $leftWin;
  83.     }
  84. }
  85.  
  86. global proc nodeOutlinerOutputsCmd(string $outWin, string $inWin)
  87. //
  88. //  Procedure Name:
  89. //      nodeOutlinerOutputsCmd
  90. //
  91. //  Description:
  92. //      sets the connectivity attribute of the rightWin to be the 
  93. //        last clicked item in the input win.
  94. //        
  95. //  Input Arguments:
  96. //      outWin - the output winodw name
  97. //      inWin - the input winodw name
  98. //
  99. //  Return Value:
  100. //      None.
  101. //
  102. {
  103.     string $tempVar; 
  104.     $tempVar = `nodeOutliner -q -lastClickedNode $outWin`; 
  105.     nodeOutliner -e -c $tempVar $inWin;
  106. }
  107.  
  108. global proc nodeOutlinerInputsCmd(string $outWin, string $inWin)
  109. //
  110. //  Procedure Name:
  111. //      nodeOutlinerInputsCmd
  112. //
  113. //  Description:
  114. //      connects the last clicked attr in the inwin
  115. //        
  116. //        
  117. //  Input Arguments:
  118. //      inWin - the input winodw name
  119. //      outWin - the output winodw name
  120. //
  121. //  Return Value:
  122. //      None.
  123. //
  124. {
  125.     int $autoConnect = `optionVar -q "connectWindowAutoConnect"`;
  126.  
  127.     if($autoConnect == 1) {
  128.         global string $rightWin, $leftWin;
  129.         string $outTemp, $inTemp, $cmd; 
  130.         $outTemp = `nodeOutliner -q -lastClickedNode $outWin` ; 
  131.         $inTemp = `nodeOutliner -q -lastClickedNode $inWin` ; 
  132.  
  133.         if($outTemp != " " && $inTemp != " ") {
  134.  
  135.             string $tokens[];
  136.             tokenize($outTemp, ".", $tokens);
  137.             int $numTokens1 = `size $tokens`;
  138.             tokenize($inTemp, ".", $tokens);
  139.             int $numTokens2 = `size $tokens`;
  140.  
  141.             if($numTokens1 > 1 && $numTokens2 > 1 ) {
  142.                 string $result;
  143.  
  144.                 string $outTempType = `nodeType $outTemp`;
  145.                 string $inTempType = `nodeType $inTemp`;
  146.  
  147.                 // must special case this - it is still possible to get unit conversion 
  148.                 // nodes to appear in the CW, and the window will not function properly
  149.                 // if the "-ignoreUnitConversion" flag is used
  150.                 //
  151.                 string $iucFlag = "-ignoreUnitConversion";
  152.                 if ( $outTempType == "unitConversion" || $inTempType == "unitConversion") {
  153.                     $iucFlag = "";
  154.                 }
  155.  
  156.                 string $conCmd = "isConnected " + $iucFlag + " " + $outTemp + " " + $inTemp;
  157.  
  158.                 if(`eval $conCmd` != 0) { 
  159.                     $cmd = ("disconnectAttr "+$outTemp+" "+$inTemp+";\n"); 
  160.                 } else { 
  161.                     $cmd = ("connectAttr -f "+$outTemp+" "+$inTemp+";\n"); 
  162.                 } 
  163.                 $result = `evalEcho $cmd`; 
  164.             }
  165.  
  166.             // redraw the window not clicked in
  167.             int $leftToRight = 1;
  168.                     
  169.             if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  170.                 $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  171.             } else {
  172.                 optionVar -iv "connectWindowLeftToRight" $leftToRight;
  173.             }
  174.  
  175.             if($leftToRight == 1) {
  176.                 nodeOutliner -e -redraw $leftWin;
  177.             } else {
  178.                 nodeOutliner -e -redraw $rightWin;
  179.             }
  180.         }
  181.     }
  182. }
  183.  
  184. global proc connectWindowValues(string $windowName)
  185. //
  186. //  Procedure Name:
  187. //      connectWindowValues
  188. //
  189. //  Description:
  190. //      updates the configure frame controls to the state
  191. //    of the node outliners.
  192. //
  193. //  Input Arguments:
  194. //        $windowName - name of the connection Window, used
  195. //        to generate the control names.
  196. //
  197. //      also uses two global variables, $rightWin and $leftWin
  198. //        Which are the names of the input and output configured nodeOutliners
  199. //        in the connect window script elsewhere in this file.
  200. //
  201. //  Return Value:
  202. //      None.
  203. //
  204. {
  205.     global string $rightWin, $leftWin;
  206.     int $value;
  207.  
  208.     if(`menuItem -exists "autoConnectCWMI"`) {
  209.         $value = `optionVar -q "connectWindowAutoConnect"`;
  210.         menuItem -e -checkBox $value "autoConnectCWMI";
  211.     }
  212.     
  213.     if(`menuItem -exists "leftSideCWInputMI"`) {
  214.         $cmd = "nodeOutliner -q -showReadOnly "+$leftWin;
  215.         $value = `eval $cmd`;
  216.         if($value == 1) {
  217.             menuItem -e -radioButton $value "leftSideCWReadOnlyMI";
  218.         } else {
  219.             $cmd = "nodeOutliner -q -showInputs "+$leftWin;
  220.             $value = `eval $cmd`;
  221.             if($value == 1) {
  222.                 menuItem -e -radioButton $value "leftSideCWInputMI";
  223.             } else {
  224.                 $cmd = "nodeOutliner -q -showOutputs "+$leftWin;
  225.                 $value = `eval $cmd`;
  226.                 menuItem -e -radioButton $value "leftSideCWOutputMI";
  227.             }
  228.         }
  229.  
  230.         $cmd = "nodeOutliner -q -showNonKeyable "+$leftWin;
  231.         $value = `eval $cmd`;
  232.         menuItem -e -checkBox $value "leftSideCWNonKeyMI";
  233.  
  234.         $cmd = "nodeOutliner -q -showConnectedOnly "+$leftWin;
  235.         $value = `eval $cmd`;
  236.         menuItem -e -checkBox $value "leftSideCWConOnlyMI";
  237.  
  238.         $cmd = "nodeOutliner -q -showHidden "+$leftWin;
  239.         $value = `eval $cmd`;
  240.         menuItem -e -checkBox $value "leftSideCWHiddenMI";
  241.  
  242.     }
  243.     
  244.     if(`menuItem -exists "rightSideCWInputMI"`) {
  245.  
  246.         $cmd = "nodeOutliner -q -showReadOnly "+$rightWin;
  247.         $value = `eval $cmd`;
  248.         if($value == 1) {
  249.             menuItem -e -radioButton $value "rightSideCWReadOnlyMI";
  250.         } else {
  251.             $cmd = "nodeOutliner -q -showInputs "+$rightWin;
  252.             $value = `eval $cmd`;
  253.             if($value == 1) {
  254.                 menuItem -e -radioButton $value "rightSideCWInputMI";
  255.             } else {
  256.                 $cmd = "nodeOutliner -q -showOutputs "+$rightWin;
  257.                 $value = `eval $cmd`;
  258.                 menuItem -e -radioButton $value "rightSideCWOutputMI";
  259.             }
  260.         }
  261.  
  262.         $cmd = "nodeOutliner -q -showNonKeyable "+$rightWin;
  263.         $value = `eval $cmd`;
  264.         menuItem -e -checkBox $value "rightSideCWNonKeyMI";
  265.  
  266.         $cmd = "nodeOutliner -q -showConnectedOnly "+$rightWin;
  267.         $value = `eval $cmd`;
  268.         menuItem -e -checkBox $value "rightSideCWConOnlyMI";
  269.  
  270.         $cmd = "nodeOutliner -q -showHidden "+$rightWin;
  271.         $value = `eval $cmd`;
  272.         menuItem -e -checkBox $value "rightSideCWHiddenMI";
  273.     }
  274. }
  275.  
  276. global proc connectWindowMenuCmd(string $itemName)
  277. //
  278. //  Procedure Name:
  279. //      connectWindowMenuCmd
  280. //
  281. //  Description:
  282. //      Command called by every item in the connect window menu
  283. //
  284. //  Input Arguments:
  285. //        $itemName - the name of the item calling this command
  286. //
  287. //      also uses two global variables, $rightWin and $leftWin
  288. //        Which are the names of the input and output configured nodeOutliners
  289. //        in the connect window script elsewhere in this file.
  290. //
  291. //  Return Value:
  292. //      None.
  293. //
  294. {
  295.     global string $leftWin, $rightWin;
  296.     int $value, $antiValue;
  297.  
  298.     if($itemName == "autoConnectCWMI") {
  299.         $value = `menuItem -q -checkBox $itemName`;
  300.         $antiValue = !$value;
  301.         optionVar -intValue "connectWindowAutoConnect" $value;
  302.         connectWinModalCmd connectWindow;
  303.     } else if ($itemName == "leftSideCWInputMI") {
  304.         $value = `menuItem -q -radioButton $itemName`;
  305.         $antiValue = !$value;
  306.         nodeOutliner -e -showInputs $value -showOutputs $antiValue -showReadOnly $antiValue $leftWin;
  307.     } else if ($itemName == "rightSideCWInputMI") {
  308.         $value = `menuItem -q -radioButton $itemName`;
  309.         $antiValue = !$value;
  310.         nodeOutliner -e -showInputs $value -showOutputs $antiValue -showReadOnly $antiValue $rightWin;
  311.     } else if ($itemName == "leftSideCWOutputMI") {
  312.         $value = `menuItem -q -radioButton $itemName`;
  313.         $antiValue = !$value;
  314.         nodeOutliner -e -showOutputs $value -showInputs $antiValue -showReadOnly $antiValue $leftWin;
  315.     } else if ($itemName == "rightSideCWOutputMI") {
  316.         $value = `menuItem -q -radioButton $itemName`;
  317.         $antiValue = !$value;
  318.         nodeOutliner -e -showOutputs $value -showInputs $antiValue -showReadOnly $antiValue $rightWin;
  319.     } else if ($itemName == "leftSideCWReadOnlyMI") {
  320.         $value = `menuItem -q -radioButton $itemName`;
  321.         $antiValue = !$value;
  322.         nodeOutliner -e -showReadOnly $value -showInputs $antiValue -showOutputs $antiValue $leftWin;
  323.     } else if ($itemName == "rightSideCWReadOnlyMI") {
  324.         $value = `menuItem -q -radioButton $itemName`;
  325.         $antiValue = !$value;
  326.         nodeOutliner -e -showReadOnly $value -showInputs $antiValue -showOutputs $antiValue $rightWin;
  327.     } else if ($itemName == "leftSideCWNonKeyMI") {
  328.         $value = `menuItem -q -checkBox $itemName`;
  329.         nodeOutliner -e -showNonKeyable $value $leftWin;
  330.         optionVar -iv "connectWindowLeftSNK" $value;
  331.     } else if ($itemName == "rightSideCWNonKeyMI") {
  332.         $value = `menuItem -q -checkBox $itemName`;
  333.         nodeOutliner -e -showNonKeyable $value $rightWin;
  334.         optionVar -iv "connectWindowRightSNK" $value;
  335.     } else if ($itemName == "leftSideCWConOnlyMI") {
  336.         $value = `menuItem -q -checkBox $itemName`;
  337.         nodeOutliner -e -showConnectedOnly $value $leftWin;
  338.         optionVar -iv "connectWindowLeftCNO" $value;
  339.     } else if ($itemName == "rightSideCWConOnlyMI") {
  340.         $value = `menuItem -q -checkBox $itemName`;
  341.         nodeOutliner -e -showConnectedOnly $value $rightWin;
  342.         optionVar -iv "connectWindowRightCNO" $value;
  343.     } else if ($itemName == "leftSideCWHiddenMI") {
  344.         $value = `menuItem -q -checkBox $itemName`;
  345.         nodeOutliner -e -showHidden $value $leftWin;
  346.         optionVar -iv "connectWindowLeftSHD" $value;
  347.     } else if ($itemName == "rightSideCWHiddenMI") {
  348.         $value = `menuItem -q -checkBox $itemName`;
  349.         nodeOutliner -e -showHidden $value $rightWin;
  350.         optionVar -iv "connectWindowRightSHD" $value;
  351.     }
  352. }
  353.  
  354. global proc connectWindowSwitchCmd(string $controlName)
  355. //
  356. //  Procedure Name:
  357. //      connectWindowSwitchCmd
  358. //
  359. //  Description:
  360. //      script to allow connections change the connection direction
  361. //    in the connect window.
  362. //
  363. //  Input Arguments:
  364. //        $controlName - which is the name of the button to be
  365. //        label changed.
  366. //
  367. //      also uses two global variables, $rightWin and $leftWin
  368. //        Which are the names of the input and output configured nodeOutliners
  369. //        in the connect window script elsewhere in this file.
  370. //
  371. //  Return Value:
  372. //      None.
  373. //
  374. {
  375.     global string $rightWin, $leftWin;
  376.  
  377.     string $cmd;
  378.  
  379.     int $outHidden = `nodeOutliner -q -showHidden $leftWin`;
  380.     int $inHidden = `nodeOutliner -q -showHidden $rightWin`;
  381.  
  382.     // get the name of the parent of the button
  383.     string $tokens[];
  384.     tokenize ( $controlName,"|",$tokens );
  385.  
  386.     string $formParent = $tokens[0];
  387.     int $i;
  388.     int $numTokens = `size $tokens`;
  389.     
  390.     for($i = 1; $i < $numTokens - 1; $i++) {
  391.         $formParent += ("|" + $tokens[$i]);
  392.     }
  393.     string $children[] = `formLayout -q -childArray $formParent`;
  394.  
  395.     // assume this layout was created by MEL function connectWindow,
  396.     // and the first two children are the labels.
  397.     // find out the state of the connection window, and 
  398.     // change the labels accordingly.
  399.  
  400.     int $autoConnect = 1;
  401.  
  402.     if(`optionVar -exists "connectWindowAutoConnect"` == 1) {
  403.         $autoConnect = `optionVar -q "connectWindowAutoConnect"`;
  404.     } else {
  405.         optionVar -iv "connectWindowLeftToRight" $autoConnect;
  406.     }
  407.  
  408.     int $leftToRight = 1;
  409.                     
  410.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  411.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  412.     } else {
  413.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  414.     }
  415.  
  416.     $phuIn = "";
  417.     $phuOut = "";
  418.     if($autoConnect) {
  419.         $phuIn = " -pressHighlightsUnconnected false ";
  420.         $phuOut = " -pressHighlightsUnconnected true ";
  421.     }
  422.  
  423.     if($leftToRight != 1) {
  424.         optionVar -iv "connectWindowLeftToRight" true;
  425.         button -e -l "from -> to" $controlName;
  426.         text -e -l "Inputs" $children[0];
  427.         text -e -l "Outputs" $children[1];
  428.         
  429.         // configure $inputs to show inputs
  430.         $cmd = ("nodeOutliner -e -multiSelect true -showInputs true -showOutputs false -showHidden "
  431.                + $outHidden + $phuIn + " -noConnectivity -selectCommand \"nodeOutlinerInputsCmd " 
  432.                + $leftWin + " " + $rightWin + "; nodeOutliner -e -r " + $rightWin
  433.                + "\" " + $rightWin);
  434.         evalEcho $cmd;        
  435.  
  436.         // configure $outputs to show outputs
  437.         $cmd = ("nodeOutliner -e -multiSelect false -showInputs false -showOutputs true -showHidden " +
  438.                $inHidden + $phuOut + " -noConnectivity -selectCommand \"nodeOutlinerOutputsCmd " + $leftWin +
  439.                " " + $rightWin + "; nodeOutliner -e -r " + $leftWin + "\" " + $leftWin);
  440.         evalEcho $cmd;        
  441.  
  442.     } else {
  443.         optionVar -iv "connectWindowLeftToRight" false;
  444.         button -e -l "to <- from" $controlName;        
  445.         text -e -l "Outputs" $children[0];
  446.         text -e -l "Inputs" $children[1];
  447.  
  448.         // configure $inputs to show outputs
  449.         $cmd = ("nodeOutliner -e -multiSelect false -noConnectivity -showInputs false -showOutputs " + 
  450.                "true -showHidden " + $outHidden + $phuOut + " -selectCommand \"nodeOutlinerOutputsCmd " + 
  451.                $rightWin + " " + $leftWin + "; nodeOutliner -e -r "+$rightWin + "\" "
  452.                + $rightWin);
  453.         evalEcho $cmd;        
  454.  
  455.         // configure $outputs to show inputs
  456.         $cmd = ("nodeOutliner -e -multiSelect true -noConnectivity -showInputs true -showOutputs false " +
  457.                "-showHidden " + $inHidden + $phuIn + " -selectCommand \"nodeOutlinerInputsCmd " + 
  458.                $rightWin + " " + $leftWin + "; nodeOutliner -e -r " + $leftWin + "\" " +
  459.                $leftWin);
  460.         evalEcho $cmd;        
  461.     }
  462.  
  463.     // update the frame
  464.     string $tokens[];
  465.     tokenize ($controlName,"|",$tokens);
  466.     
  467.     connectWindowValues $tokens[0];
  468.  
  469.     if(`popupMenu -exists leftPropagateMenu`) {
  470.         popupMenu -e -deleteAllItems leftPropagateMenu;
  471.     }
  472. }
  473.  
  474. global proc connectWindowClearCmd()
  475. //
  476. //  Procedure Name:
  477. //      connectWindowClearCmd
  478. //
  479. //  Description:
  480. //      empty the contents of the window
  481. //
  482. //  Input Arguments:
  483. //      none, but uses two global variables, $rightWin and $leftWin
  484. //        Which are the names of the input and output configured nodeOutliners
  485. //        in the connect window script elsewhere in this file.
  486. //
  487. //  Return Value:
  488. //      None.
  489. //
  490. {
  491.     global string $rightWin;
  492.     global string $leftWin;
  493.     global string $connectWinLeftLabel;
  494.     global string $connectWinRightLabel;
  495.  
  496.     string $cmd = ("nodeOutliner -q -nd \""+$rightWin+ "\"");
  497.     string $contents[] = `eval $cmd`;
  498.  
  499.     int $numNodes = `size $contents`;
  500.     int $i;
  501.     
  502.     $cmd = "nodeOutliner -e -noConnectivity";
  503.     for($i = 0; $i < $numNodes; $i++) {
  504.         $cmd += " -remove " + $contents[$i];
  505.     }
  506.     $cmd += (" \"" + $rightWin + "\"");
  507.     eval $cmd;
  508.     
  509.     $cmd = ("nodeOutliner -q -nd "+$leftWin);
  510.     $contents = `eval $cmd`;
  511.     $numNodes = `size $contents`;
  512.  
  513.     $cmd = "nodeOutliner -e -noConnectivity";
  514.     for($i = 0; $i < $numNodes; $i++) {
  515.         $cmd += ("-remove " + $contents[$i] + " ");
  516.     }
  517.     $cmd += ("\"" + $leftWin + "\"");
  518.     eval $cmd;
  519.  
  520.     if(`popupMenu -exists rightPropagateMenu`) {
  521.         popupMenu -e -deleteAllItems rightPropagateMenu;
  522.     }
  523.     if(`popupMenu -exists leftPropagateMenu`) {
  524.         popupMenu -e -deleteAllItems leftPropagateMenu;
  525.     }
  526.  
  527.     text -e -l " " $connectWinLeftLabel;
  528.     text -e -l " " $connectWinRightLabel;
  529. }
  530.  
  531. global proc connectWindowRemoveCmd()
  532. //
  533. //  Procedure Name:
  534. //      connectWindowRemoveCmd
  535. //
  536. //  Description:
  537. //      remove the highlighted items from display in the window
  538. //        reset the connectivity in the input window if the connectivity 
  539. //        happens to be the one deleted.
  540. //
  541. //  Input Arguments:
  542. //      none, but uses two global variables, $rightWin and $leftWin
  543. //        Which are the names of the input and output configured nodeOutliners
  544. //        in the connect window script elsewhere in this file.
  545. //
  546. //  Return Value:
  547. //      None.
  548. //
  549. {
  550.     global string $rightWin;
  551.     global string $leftWin;
  552.     global string $connectWinLeftLabel;
  553.     global string $connectWinRightLabel;
  554.  
  555.     int $leftToRight = 1;
  556.                     
  557.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  558.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  559.     } else {
  560.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  561.     }
  562.  
  563.     // remove from right win
  564.  
  565.     string $cmd = ("nodeOutliner -q -currentSelection "+$rightWin);
  566.     string $contents[] = `eval $cmd`;
  567.     string $connectivity = "";
  568.     
  569.     int $numNodes = `size $contents`;
  570.     
  571.     if ( $numNodes > 0 ) {
  572.         if(! $leftToRight) {
  573.             $connectivity = `nodeOutliner -q -connectivity $leftWin`;
  574.         }
  575.  
  576.         $cmd = "nodeOutliner -e ";
  577.         for($node in $contents) {
  578.             $cmd += ("-remove " + $node + " ");
  579.             if($connectivity == $node) {
  580.                 nodeOutliner -e -noConnectivity $leftWin;
  581.             }
  582.         }
  583.         $cmd += $rightWin;
  584.         eval $cmd;
  585.  
  586.         // reset the label
  587.         $contents = `nodeOutliner -q -nd $rightWin`;
  588.         $numNodes = `size $contents`;
  589.         if ( $numNodes > 0 ) {
  590.             text -e -l $contents[0] $connectWinRightLabel;
  591.         } else {
  592.             text -e -l " " $connectWinRightLabel;            
  593.         }
  594.     }
  595.     
  596.     // remove from output win
  597.     $cmd = ("nodeOutliner -q -currentSelection "+$leftWin);
  598.     $contents = `eval $cmd`;
  599.  
  600.     $numNodes = `size $contents`;
  601.     
  602.     if ( $numNodes > 0 ) {
  603.         if($leftToRight) {
  604.             $connectivity = `nodeOutliner -q -connectivity $rightWin`;
  605.         }
  606.  
  607.         $cmd = "nodeOutliner -e ";
  608.         for($node in $contents) {
  609.             $cmd += ("-remove " + $node + " ");
  610.             if($connectivity == $node) {
  611.                 nodeOutliner -e -noConnectivity $rightWin;
  612.             }
  613.         }
  614.         $cmd += $leftWin;
  615.         eval $cmd;
  616.  
  617.         // reset the label
  618.         $contents = `nodeOutliner -q -nd $leftWin`;
  619.         $numNodes = `size $contents`;
  620.         if ( $numNodes > 0 ) {
  621.             text -e -l $contents[0] $connectWinLeftLabel;
  622.         } else {
  623.             text -e -l " " $connectWinLeftLabel;            
  624.         }
  625.     }
  626.     if(`popupMenu -exists rightPropagateMenu`) {
  627.         popupMenu -e -deleteAllItems rightPropagateMenu;
  628.     }
  629.     if(`popupMenu -exists leftPropagateMenu`) {
  630.         popupMenu -e -deleteAllItems leftPropagateMenu;
  631.     }
  632. }
  633.  
  634. global proc connectWindowBreakCmd()
  635. //
  636. //  Procedure Name:
  637. //      connectWindowBreakCmd
  638. //
  639. //  Description:
  640. //      script for breaking the connections between highlighted 
  641. //        attributes in the node connection window.
  642. //
  643. //  Input Arguments:
  644. //      none, but uses two global variables, $rightWin and $leftWin
  645. //        Which are the names of the input and output configured nodeOutliners
  646. //        in the connect window script elsewhere in this file.
  647. //
  648. //  Return Value:
  649. //      None.
  650. //
  651. {
  652.     global string $rightWin;
  653.     global string $leftWin;
  654.  
  655.     // get current selections in both windows
  656.  
  657.     string $cmd = ("nodeOutliner -q -currentSelection "+$rightWin);
  658.     string $input[] = `evalEcho $cmd`;
  659.  
  660.     // remove from output win
  661.  
  662.     $cmd = ("nodeOutliner -q -currentSelection "+$leftWin);
  663.     string $output[] = `evalEcho $cmd`;
  664.  
  665.     int $leftToRight = 1;
  666.                     
  667.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  668.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  669.     } else {
  670.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  671.     }
  672.  
  673.     int $numNodes;
  674.     
  675.     if($leftToRight != 1) {
  676.         $numNodes = `size $output`;
  677.  
  678.         if( `size $input` == 1 && $numNodes > 0) {
  679.             int $i;
  680.             for($i = 0; $i < $numNodes; $i++) {
  681.                 $cmd = ("disconnectAttr " + $input[0] + " " + $output[$i]);
  682.                 evalEcho $cmd;
  683.             }
  684.         }
  685.     } else {
  686.         $numNodes = `size $input`;
  687.  
  688.         if( `size $output` == 1 && $numNodes > 0) {
  689.             int $i;
  690.             for($i = 0; $i < $numNodes; $i++) {
  691.                 $cmd = ("disconnectAttr " + $output[0] + " " + $input[$i]);
  692.                 evalEcho $cmd;
  693.             }
  694.         }
  695.     }
  696.  
  697.     // redraw both windows
  698.     nodeOutliner -e -redraw $leftWin;
  699.     nodeOutliner -e -redraw $rightWin;
  700.  
  701.     if(`popupMenu -exists rightPropagateMenu`) {
  702.         popupMenu -e -deleteAllItems rightPropagateMenu;
  703.     }
  704.     if(`popupMenu -exists leftPropagateMenu`) {
  705.         popupMenu -e -deleteAllItems leftPropagateMenu;
  706.     }
  707. }
  708.  
  709. global proc connectWindowMakeCmd()
  710. //
  711. //  Procedure Name:
  712. //      connectWindowMakeCmd
  713. //
  714. //  Description:
  715. //      script for making the connections between highlighted attributes in the 
  716. //        node connection window.
  717. //
  718. //  Input Arguments:
  719. //      none, but uses two global variables, $rightWin and $leftWin
  720. //        Which are the names of the input and output configured nodeOutliners
  721. //        in the connect window script elsewhere in this file.
  722. //
  723. //  Return Value:
  724. //      None.
  725. //
  726. {
  727.     global string $rightWin;
  728.     global string $leftWin;
  729.  
  730.     // get current selections in both windows
  731.     //
  732.     string $cmd = ("nodeOutliner -q -currentSelection "+$rightWin);
  733.     string $input[] = `evalEcho $cmd`;
  734.  
  735.     // remove from output win
  736.     //
  737.     $cmd = ("nodeOutliner -q -currentSelection "+$leftWin);
  738.     string $output[] = `evalEcho $cmd`;
  739.  
  740.     int $numNodes;
  741.     string $result;
  742.     
  743.     int $leftToRight = 1;
  744.                     
  745.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  746.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  747.     } else {
  748.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  749.     }
  750.  
  751.     if($leftToRight) {
  752.         $numNodes = `size $input`;
  753.         if( `size $output` == 1 && $numNodes > 0) {
  754.             int $i;
  755.             for($i = 0; $i < $numNodes; $i++) {
  756.                 $cmd = ("connectAttr -f " + $output[0] + " " +$input[$i]);
  757.                 $result = `evalEcho $cmd`;
  758.             }
  759.         }
  760.     } else {
  761.         $numNodes = `size $output`;
  762.         if( `size $input` == 1 && $numNodes > 0) {
  763.             int $i;
  764.             for($i = 0; $i < $numNodes; $i++) {
  765.                 $cmd = ("connectAttr -f " + $input[0] + " " +$output[$i]);
  766.                 $result = `evalEcho $cmd`;
  767.             }
  768.         }
  769.     }
  770.  
  771.     // redraw both windows
  772.     nodeOutliner -e -redraw $leftWin;
  773.     nodeOutliner -e -redraw $rightWin;
  774.  
  775.     if(`popupMenu -exists rightPropagateMenu`) {
  776.         popupMenu -e -deleteAllItems rightPropagateMenu;
  777.     }
  778.     if(`popupMenu -exists leftPropagateMenu`) {
  779.         popupMenu -e -deleteAllItems leftPropagateMenu;
  780.     }
  781. }
  782.  
  783. global proc connectWindowAddToLeft(string $nodeName)
  784. //
  785. //  Procedure Name:
  786. //      connectWindowAddToLeft
  787. //
  788. //  Description:
  789. //      Add the named node to the left side of the connection window
  790. //
  791. //  Input Arguments:
  792. //        $nodeName, expected to be either a node's name or a node.attribute
  793. //      also uses the global variable $leftWin
  794. //        the nodeOutliner on the left side of the connect
  795. //        window script elsewhere in this file.
  796. //
  797. //  Return Value:
  798. //      None.
  799. //
  800. {
  801.     global string $leftWin;
  802.     global string $connectWinLeftLabel;
  803.  
  804.     string $tokens[];
  805.     tokenize ($nodeName,".",$tokens);
  806.  
  807.     if(`window -exists "connectWindow"`) {
  808.         nodeOutliner -e -addObject $tokens[0] -noConnectivity $leftWin;
  809.          text -e -l $nodeName $connectWinLeftLabel;
  810.     }
  811.     if(`popupMenu -exists leftPropagateMenu`) {
  812.         popupMenu -e -deleteAllItems leftPropagateMenu;
  813.     }
  814. }
  815.  
  816. global proc connectWindowSetLeftLabel(string $label)
  817. //
  818. //  Procedure Name:
  819. //      connectWindowSetLeftLabel
  820. //
  821. //  Description:
  822. //      Set the left label on the left side to the input string
  823. //
  824. //  Input Arguments:
  825. //        $label - the new label value.
  826. //
  827. //  Return Value:
  828. //      None.
  829. //
  830. {
  831.     global string $connectWinLeftLabel;
  832.  
  833.     if(`window -exists "connectWindow"`) {
  834.          text -e -l $label $connectWinLeftLabel;
  835.     }
  836. }
  837.  
  838. global proc connectWindowFillFromActiveList(int $side )
  839. //
  840. //  Procedure Name:
  841. //      connectWindowFillFromActiveList
  842. //
  843. //  Description:
  844. //      Load what's active into one side of the connection window
  845. //
  846. //  Input Arguments:
  847. //      $side: 0 will replace the left side, != 0 will replace the right
  848. //
  849. //  Return Value:
  850. //      None.
  851. //
  852. {
  853.     global string $leftWin;
  854.     global string $rightWin;
  855.  
  856.     if(`window -exists "connectWindow"`) {
  857.  
  858.         string $nodeOutlinerName;
  859.  
  860.         if( $side == 0 ) {
  861.             $nodeOutlinerName = $leftWin;
  862.             if(`popupMenu -exists leftPropagateMenu`) {
  863.                 popupMenu -e -deleteAllItems leftPropagateMenu;
  864.             }
  865.         } else {
  866.             $nodeOutlinerName = $rightWin;
  867.             if(`popupMenu -exists rightPropagateMenu`) {
  868.                 popupMenu -e -deleteAllItems rightPropagateMenu;
  869.             }
  870.         }
  871.  
  872.         string $active[];
  873.         $active = `ls -sl`;
  874.  
  875.         int $numActive = `size $active`;
  876.         
  877.         if( $numActive > 0) {
  878.             string $cmd = ("nodeOutliner -e -replace " + $active[0] + " " + $nodeOutlinerName);
  879.             evalEcho $cmd;
  880.  
  881.             // If the outputs window is being refreshed, force a refresh
  882.             // and re-setting of connectivity parameters of the inputs
  883.             // window, so any rows that are dimmed will be undimmed.
  884.             //
  885.             int $leftToRight = 1;
  886.             if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  887.                 $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  888.             }
  889.  
  890.             if ($leftToRight == 1)
  891.             {
  892.                 // If outputs are in the left window and the left window
  893.                 // has been re-loaded, clear the connectivity of the
  894.                 // right window so it will refresh.
  895.                 //
  896.                 if ($nodeOutlinerName == $leftWin)
  897.                 {
  898.                     nodeOutliner -e -nc $rightWin;
  899.                 }
  900.             }
  901.             else
  902.             {
  903.                 // If outputs are in the right window and the right window
  904.                 // has a new node in it, clear the connectivity of the left
  905.                 // window so it will refresh.
  906.                 //
  907.                 if ($nodeOutlinerName == $rightWin)
  908.                 {
  909.                     nodeOutliner -e -nc $leftWin;
  910.                 }
  911.             }
  912.  
  913.             if($numActive > 1) {
  914.                 int $i;
  915.                 for($i = 1; $i < $numActive; $i++) {
  916.                     $cmd = ("nodeOutliner -e -addObject " + $active[$i] + " " + $nodeOutlinerName);
  917.                     evalEcho $cmd;
  918.                 }
  919.             }
  920.         }
  921.     }
  922. }
  923.  
  924. global proc connectWindowAddToRight(string $nodeName)
  925. //
  926. //  Procedure Name:
  927. //      connectWindowAddToRight
  928. //
  929. //  Description:
  930. //      Add the named node to the right side of the connection window
  931. //
  932. //  Input Arguments:
  933. //        $nodeName, expected to be either a node's name or a node.attribute
  934. //      also uses the global variable $leftWin
  935. //        the nodeOutliner on the left side of the connect
  936. //        window script elsewhere in this file.
  937. //
  938. //  Return Value:
  939. //      None.
  940. //
  941. {
  942.     global string $rightWin;
  943.     global string $connectWinRightLabel;
  944.  
  945.     string $tokens[];
  946.     tokenize ($nodeName,".",$tokens);
  947.  
  948.     if(`window -exists "connectWindow"`) {
  949.         nodeOutliner -e -addObject $tokens[0] -nc $rightWin;
  950.          text -e -l $nodeName $connectWinRightLabel;
  951.     }
  952.     if(`popupMenu -exists rightPropagateMenu`) {
  953.         popupMenu -e -deleteAllItems rightPropagateMenu;
  954.     }
  955. }
  956.  
  957. global proc connectWindowSetRightLabel(string $label)
  958. //
  959. //  Procedure Name:
  960. //      connectWindowSetRightLabel
  961. //
  962. //  Description:
  963. //      Set the right label on the right side to the input string
  964. //
  965. //  Input Arguments:
  966. //        $label - the new label value.
  967. //
  968. //  Return Value:
  969. //      None.
  970. //
  971. {
  972.     global string $connectWinRightLabel;
  973.  
  974.     if(`window -exists "connectWindow"`) {
  975.          text -e -l $label $connectWinRightLabel;
  976.     }
  977. }
  978.  
  979. //
  980. //  Procedure Name:
  981. //      CWpropagateMenuCB
  982. //
  983. //  Description:
  984. //      "pages over" the connect window.  the contents of one side move
  985. //        to the opposite window, and a given node is loaded to the empty side.
  986. //
  987. //  Input Arguments:
  988. //        $side - "-left" to page left, "-right" to page right.
  989. //        $nodes - a string in the form "node1 node2 node3 ... nodeX"
  990. //            representing the nodes to load into the outliner opposite $side.
  991. //        $menu1, $menu2 - the names of the two menus so they can be cleared.
  992. //
  993. //  Return Value:
  994. //      None.
  995. //
  996. global proc CWpropagateMenuCB(string $side, string $nodes, string $menu1, string $menu2)
  997. {
  998.     global string $leftWin, $rightWin;
  999.     string $clearWin, $shuffleWin;
  1000.     
  1001.     string $contents[];
  1002.     int $leftToRight = 1;
  1003.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  1004.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  1005.     } else {
  1006.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  1007.     }
  1008.     if ($side == "-left") {
  1009.         $clearWin = $leftWin;
  1010.         $shuffleWin = $rightWin;
  1011.     } else if ($side == "-right") {
  1012.         $clearWin = $rightWin;
  1013.         $shuffleWin = $leftWin;
  1014.     }
  1015.  
  1016.     $contents = `nodeOutliner -q -nodesDisplayed $clearWin`;
  1017.  
  1018.     nodeOutliner -e -removeAll $leftWin;
  1019.     nodeOutliner -e -removeAll $rightWin;
  1020.  
  1021.     string $nodeArray[];
  1022.     tokenize ($nodes," ",$nodeArray);
  1023.     for($node in $nodeArray) {
  1024.         nodeOutliner -e -addObject $node -nc $clearWin;
  1025.     }
  1026.     for($thing in $contents) {
  1027.         nodeOutliner -e -addObject $thing -nc $shuffleWin;
  1028.     }
  1029.  
  1030.     popupMenu -e -deleteAllItems $menu1;
  1031.     popupMenu -e -deleteAllItems $menu2;
  1032. }
  1033.  
  1034. //
  1035. //  Procedure Name:
  1036. //      CWpropagateMenu
  1037. //
  1038. //  Description:
  1039. //      Fills a popup menu with the currently connected attr names.
  1040. //        Depending on the input strings and the connect window configuration.
  1041. //
  1042. //  Input Arguments:
  1043. //        $side - "-left" for the left button, "-right" for the right button.
  1044. //        $menu - the name of the menu holding the items
  1045. //        $otherMenu - the name of the opposite menu
  1046. //
  1047. //  Return Value:
  1048. //      None.
  1049. //
  1050. global proc CWpropagateMenu(string $side, string $menu, string $otherMenu)
  1051. {
  1052.     global string $rightWin, $leftWin;
  1053.     setParent -m $menu;
  1054.  
  1055.     popupMenu -e -deleteAllItems $menu;
  1056.  
  1057.     int $leftToRight = 1;
  1058.     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  1059.         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  1060.     } else {
  1061.         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  1062.     }
  1063.  
  1064.     string $nodes[];
  1065.     if ($side == "-left") {
  1066.         $nodes = `nodeOutliner -q -nodesDisplayed $leftWin`;
  1067.     } else {
  1068.         $nodes = `nodeOutliner -q -nodesDisplayed $rightWin`;
  1069.     }
  1070.  
  1071.     int $i,$numcons,$showconn = true,$count = 0;
  1072.     string $connections[];
  1073.     string $nodeArray[];
  1074.     string $types[];
  1075.     string $class[];    
  1076.     string $nearplug,$farplug;
  1077.     
  1078.     if (($side == "-left" && $leftToRight == 1) ||
  1079.         ($side == "-right" && $leftToRight == 0)
  1080.         ) {
  1081.  
  1082.         for ($node in $nodes) {
  1083.             if($count > 0) {
  1084.                 menuItem -divider true;
  1085.             }
  1086.  
  1087.             catch ($connections =
  1088.                    `listConnections -s true -d false -c true -p true $node`);
  1089.             $numcons = size($connections);
  1090.             
  1091.             for ($i = 0; $i < $numcons; $i+=2) {
  1092.                 $nearplug = $connections[$i]; 
  1093.                 $farplug = $connections[$i+1];
  1094.                 tokenize($farplug, ".", $nodeArray);
  1095.                 menuItem -l ($farplug + "->" + $nearplug)
  1096.                     -c ("CWpropagateMenuCB "+$side + " " + $farplug + 
  1097.                         " " + $menu + " " + $otherMenu);
  1098.             }
  1099.             $count++;
  1100.             clear $connections;
  1101.             clear $nodeArray;
  1102.         }
  1103.     } else {
  1104.         for ($node in $nodes) {
  1105.             if($count > 0) {
  1106.                 menuItem -divider true;
  1107.             }
  1108.             
  1109.             catch ($connections = 
  1110.                    `listConnections -s false -d true -p true -c true $node`);
  1111.             $numcons = size($connections);
  1112.             
  1113.             for ($i = 0; $i < $numcons; $i+=2) {
  1114.                 $nearplug = $connections[$i]; 
  1115.                 $farplug = $connections[$i+1];
  1116.                 tokenize($farplug, ".", $nodeArray);
  1117.  
  1118.                 if($nearplug == ($node + ".message")) {
  1119.                     $types = `ls -showType $nodeArray[0]`;
  1120.                     if(size($types) > 0) {
  1121.                         $class = `getClassification $types[1]`;
  1122.                         if(! ($class[0] != "" || $types[1] == "renderGlobals" ||
  1123.                             $types[1] == "camera" || $types[1] == "imagePlane")) {
  1124.                             $showconn = false;
  1125.                         }
  1126.                         clear $class;
  1127.                     }
  1128.                     clear $types;
  1129.                 }
  1130.  
  1131.                 if($showconn) {
  1132.                     menuItem -l ($nearplug + "->" + $farplug) -c 
  1133.                         ("CWpropagateMenuCB "+$side + " " + $nodeArray[0]
  1134.                          + " " + $menu + " " + $otherMenu);
  1135.                 }
  1136.                 $showconn = true;
  1137.             }
  1138.             $count++;
  1139.             clear $connections;
  1140.             clear $nodeArray;
  1141.         }
  1142.     }
  1143. }
  1144.  
  1145. //
  1146. //  Procedure Name:
  1147. //      CWpopupMenuCB
  1148. //
  1149. //  Description:
  1150. //      Callback for the right mouse button popup menu on the nodeOutliner.
  1151. //        Adds the last selected menu label to the opposite window.
  1152. //
  1153. //  Input Arguments:
  1154. //        $nodeOutliner - the node outliner calling this command.
  1155. //
  1156. //  Return Value:
  1157. //      None.
  1158. //
  1159. global proc CWpopupMenuCB(string $nodeOutliner)
  1160. {
  1161.     global string $leftWin, $rightWin;
  1162.     string $cmd = "nodeOutliner -q -lastMenuChoice " + $nodeOutliner;
  1163.     string $label = `eval $cmd`;
  1164.     
  1165.     if($label != "Next Available") {
  1166.         if($nodeOutliner == $leftWin) {
  1167.             connectWindowAddToRight $label;
  1168.         } else {
  1169.             connectWindowAddToLeft $label;
  1170.         }
  1171.     }
  1172. }
  1173.  
  1174. //
  1175. //  Procedure Name:
  1176. //      CWpropagateButtonCB
  1177. //
  1178. //  Description:
  1179. //      "pages over" the connect window.  the contents of one side move
  1180. //        to the opposite window, and a given node is loaded to the empty side.
  1181. //        Will use the first option, if any, present in the menu
  1182. //
  1183. //  Input Arguments:
  1184. //        $type - "-left" to page left, "-right" to page right.
  1185. //        $menu - the name of the menu of the button
  1186. //        $otherMenu - the name of the menu of the other button 
  1187. //
  1188. //  Return Value:
  1189. //      None.
  1190. //
  1191. global proc CWpropagateButtonCB(string $type, string $menu, string $otherMenu)
  1192. {
  1193.     int $numItems = `popupMenu -query -numberOfItems $menu`;
  1194.     if($numItems == 0) {
  1195.         CWpropagateMenu $type $menu $otherMenu;
  1196.         $numItems = `popupMenu -query -numberOfItems $menu`;
  1197.     }
  1198.     
  1199.     string $items[] = `popupMenu -query -itemArray $menu`;
  1200.     $numItems = `size $items`;
  1201.     if($numItems > 0) {
  1202.         string $command = `menuItem -query -command $items[0]`;
  1203.         eval $command;
  1204.     }
  1205.  
  1206.     popupMenu -e -deleteAllItems $menu;
  1207.     popupMenu -e -deleteAllItems $otherMenu;
  1208. }
  1209.  
  1210. global proc buildCWConfigureMenu (string $menu, string $outLinerName, string $idString)
  1211. //
  1212. //  Procedure Name:
  1213. //      buildCWConfigureMenu
  1214. //
  1215. //  Description:
  1216. //      Creates the menus for configuring half of the connect window
  1217. //
  1218. //  Input Arguments:
  1219. //        string $menu - the name of the menu that the items will belong to.
  1220. //        string $outLinerName - the name of the nodeOutliner to edit.
  1221. //        string $idString - A unique key string to construct the optionVar default 
  1222. //            string for the filter menu options. values : "Left" or "Right"
  1223. //
  1224. //  Return Value:
  1225. //      None.
  1226. //
  1227. {
  1228.     string $itemName;
  1229.     // assume that the menu parent is properly set.
  1230.     //
  1231.     $itemName = $outLinerName + "OutputMI";
  1232.     if(!`menuItem -exists $itemName`) {
  1233.  
  1234.         setParent -menu $menu;
  1235.         
  1236.         radioMenuItemCollection ($menu + "Filters");
  1237.  
  1238.             menuItem -l "Show Readable" -p $menu -radioButton false
  1239.                 -command ("connectWindowMenuCmd " + $itemName)
  1240.             $itemName;
  1241.  
  1242.             $itemName = $outLinerName + "ReadOnlyMI";
  1243.             menuItem -l "Show Outputs Only" -p $menu -radioButton false 
  1244.                 -command ("connectWindowMenuCmd " + $itemName)
  1245.             $itemName;
  1246.  
  1247.             $itemName = $outLinerName + "InputMI";
  1248.             menuItem -l "Show Inputs Only" -p $menu -radioButton false 
  1249.                 -command ("connectWindowMenuCmd " + $itemName)
  1250.             $itemName;
  1251.  
  1252.         menuItem -p $menu -divider true;
  1253.  
  1254.         // find the default value, if any for the non-keyable filter
  1255.         //
  1256.         int $menuSetVal = true;
  1257.  
  1258.         if(`optionVar -exists ("connectWindow" + $idString + "SNK")` == 1) {
  1259.             $menuSetVal = `optionVar -q ("connectWindow" + $idString + "SNK")`;
  1260.         } else {
  1261.             optionVar -iv ("connectWindow" + $idString + "SNK") $menuSetVal;
  1262.         }
  1263.  
  1264.         $itemName = $outLinerName + "NonKeyMI";
  1265.         menuItem -l "Show Non-Keyable" -p $menu -checkBox $menuSetVal
  1266.             -command ("connectWindowMenuCmd " + $itemName)
  1267.         $itemName;
  1268.  
  1269.         $menuSetVal = false;
  1270.  
  1271.         if(`optionVar -exists ("connectWindow" + $idString + "CNO")` == 1) {
  1272.             $menuSetVal = `optionVar -q ("connectWindow" + $idString + "CNO")`;
  1273.         } else {
  1274.             optionVar -iv ("connectWindow" + $idString + "CNO") $menuSetVal;
  1275.         }
  1276.  
  1277.         $itemName = $outLinerName + "ConOnlyMI";
  1278.         menuItem -l "Show Connected Only" -p $menu -checkBox $menuSetVal
  1279.             -command ("connectWindowMenuCmd " + $itemName)
  1280.         $itemName;
  1281.  
  1282.         $menuSetVal = false;
  1283.  
  1284.         if(`optionVar -exists ("connectWindow" + $idString + "SHD")` == 1) {
  1285.             $menuSetVal = `optionVar -q ("connectWindow" + $idString + "SHD")`;
  1286.         } else {
  1287.             optionVar -iv ("connectWindow" + $idString + "SHD") $menuSetVal;
  1288.         }
  1289.  
  1290.         $itemName = $outLinerName + "HiddenMI";
  1291.         menuItem -l "Show Hidden" -p $menu -checkBox $menuSetVal 
  1292.             -command ("connectWindowMenuCmd " + $itemName)    
  1293.         $itemName;
  1294.  
  1295.         connectWindowValues "connectWindow";
  1296.     }
  1297. }
  1298.  
  1299. global proc buildConnectContextHelpItems(string $nameRoot, string $menuParent)
  1300. //
  1301. //  Description:
  1302. //        Build context sensitive menu items
  1303. //        
  1304. //  Input Arguments:
  1305. //        $nameRoot - name to use as the root of all item names
  1306. //        $menuParent - the name of the parent of this menu
  1307. //
  1308. //  Return Value:
  1309. //      None
  1310. //
  1311. {
  1312.     menuItem -label "Help on Connection Editor..."
  1313.         -enableCommandRepeat false
  1314.         -command "showHelp ConnectionEditor";
  1315. }
  1316.  
  1317. proc buildConnectWindowMenu ()
  1318. //
  1319. //  Procedure Name:
  1320. //      buildConnectWindowMenu
  1321. //
  1322. //  Description:
  1323. //      Creates the menus for the connection window
  1324. //
  1325. //  Input Arguments:
  1326. //        None.
  1327. //
  1328. //  Return Value:
  1329. //      None.
  1330. //
  1331. {
  1332.     global string $rightWin, $leftWin;
  1333.     string $itemName;
  1334.     string $tokens[];
  1335.     int $numTokens;
  1336.     string $noName = "nodeOutlinerName";
  1337.     
  1338.     // assume that the menu parent is properly set.
  1339.     menu -l "Options" 
  1340.         -tearOff true
  1341.         -postMenuCommandOnce true
  1342.         -familyImage "menuIconOptions.xpm";
  1343.         menuItem -l "Auto-connect" -checkBox 1 
  1344.             -command ("connectWindowMenuCmd autoConnectCWMI") 
  1345.         "autoConnectCWMI";
  1346.     setParent -menu ..;
  1347.  
  1348.     tokenize ($leftWin, "|", $tokens);
  1349.     $numTokens = `size $tokens`;
  1350.     if($numTokens > 0) {
  1351.         $numTokens--;
  1352.         $noName = $tokens[$numTokens];
  1353.     }
  1354.     menu -l "Left Display" 
  1355.         -tearOff true 
  1356.         -postMenuCommandOnce true
  1357.         -postMenuCommand ("buildCWConfigureMenu leftSideCWM " + $noName + " Left") 
  1358.         -familyImage "menuIconLeftSideFilters.xpm"
  1359.         leftSideCWM;
  1360.     setParent -menu ..;
  1361.  
  1362.     tokenize ($rightWin, "|", $tokens);
  1363.     $numTokens = `size $tokens`;
  1364.     if($numTokens > 0) {
  1365.         $numTokens--;
  1366.         $noName = $tokens[$numTokens];
  1367.     }
  1368.     menu -l "Right Display" 
  1369.         -tearOff true 
  1370.         -postMenuCommandOnce true
  1371.         -postMenuCommand ("buildCWConfigureMenu rightSideCWM " + $noName + " Right") 
  1372.         -familyImage "menuIconRightSideFilters.xpm"
  1373.         rightSideCWM;
  1374.     setParent -menu ..;
  1375.  
  1376.     //    Adds support for the Context Sensitive Help Menu.
  1377.     //
  1378.     addContextHelpProc "connectWindow" "buildConnectContextHelpItems";
  1379.  
  1380.     doHelpMenu "connectWindow" "connectWindow";
  1381.  
  1382.     connectWindowValues "connectWindow";
  1383. }
  1384.  
  1385. global proc connectWindow ()
  1386. //
  1387. //  Procedure Name:
  1388. //      connectWindow
  1389. //
  1390. //  Description:
  1391. //      Creates a window with some buttons and two node outliners,
  1392. //        Connected and separately configured
  1393. //
  1394. //  Input Arguments:
  1395. //        None.
  1396. //
  1397. //  Return Value:
  1398. //      None.
  1399. //
  1400. {
  1401.     global string $rightWin;
  1402.     global string $leftWin;
  1403.  
  1404.     if(`window -exists "connectWindow"`) {
  1405.         connectWindowClearCmd;
  1406.         showWindow connectWindow;
  1407.     } else {
  1408.         window -rtf 0 -h 620 -w 520 
  1409.             -title "Connection Editor" 
  1410.             -iconName "Connection" 
  1411.             connectWindow;
  1412.  
  1413.         string $aTab = `menuBarLayout tl`;
  1414.         
  1415.             string $aForm = `formLayout -p $aTab cwForm`;
  1416.  
  1417.                 int $autoConnect = true;
  1418.                 int $modal = false;
  1419.                     
  1420.                 if(`optionVar -exists "connectWindowAutoConnect"` == 1) {
  1421.                     $autoConnect = `optionVar -q "connectWindowAutoConnect"`;
  1422.                 } else {
  1423.                     optionVar -iv "connectWindowAutoConnect" $autoConnect;
  1424.                 }
  1425.                         
  1426.                 if($autoConnect == 0) {
  1427.                     $modal = true;
  1428.                 }
  1429.  
  1430.                    string $leftActiveBtn = `button -l "Reload Left" -p $aForm 
  1431.                                         -c "connectWindowFillFromActiveList 0" 
  1432.                                         -ann "Replace Left Side contents with current Selection"
  1433.                                         fillLeft`;
  1434.                    string $rightActiveBtn = `button -l "Reload Right" -p $aForm 
  1435.                                         -ann "Replace Right Side contents with current Selection"
  1436.                                          -c "connectWindowFillFromActiveList 1" 
  1437.                                          fillRight`;
  1438.  
  1439.                 string $labelForm = `formLayout labelForm`;
  1440.                        string $inputText = `text -p $labelForm -l "Inputs" 
  1441.                                         -al "center" inputText`;
  1442.                     string $outputText = `text -p $labelForm -l "Outputs" 
  1443.                                          -al "center" outputText`;
  1444.  
  1445.                     string $switchBut = `button -p $labelForm -l "from -> to" 
  1446.                                         -ann "Change to connecting in the opposite direction"
  1447.                                         switchBut`;
  1448.                     button -e -c ("connectWindowSwitchCmd "+ $switchBut) $switchBut;
  1449.                 setParent ..;
  1450.  
  1451.                 formLayout -e 
  1452.                     -af inputText "top" 1
  1453.                     -af inputText "bottom" 1
  1454.                     -ap inputText "right" -50 75
  1455.                     
  1456.                     -af switchBut "top" 1
  1457.                     -af switchBut "bottom" 1
  1458.                     -ap switchBut "right" 0 65
  1459.                     -ap switchBut "left" 0 35
  1460.  
  1461.                     -af outputText "top" 1 
  1462.                     -af outputText "bottom" 1
  1463.                     -ap outputText "left" -50 25
  1464.  
  1465.                 $labelForm;
  1466.  
  1467.                 string $connectPane = `paneLayout -configuration "vertical2" 
  1468.                                       -separatorThickness 5 -height 300 -paneSize 1 50 100 
  1469.                                       -paneSize 1 50 100
  1470.                                       connectWindowPane`;
  1471.  
  1472.                     // get some value defaults for the left side nodeOutliner.
  1473.                     //
  1474.                     int $defaultSNK = true;
  1475.                     int $defaultCNO = false;
  1476.                     int $defaultSHD = false;
  1477.  
  1478.                     if(`optionVar -exists ("connectWindowLeftSNK")` == 1) {
  1479.                         $defaultSNK = `optionVar -q ("connectWindowLeftSNK")`;
  1480.                     } else {
  1481.                         optionVar -iv ("connectWindowLeftSNK") $defaultSNK;
  1482.                     }
  1483.  
  1484.                     if(`optionVar -exists ("connectWindowLeftCNO")` == 1) {
  1485.                         $defaultCNO = `optionVar -q ("connectWindowLeftCNO")`;
  1486.                     } else {
  1487.                         optionVar -iv ("connectWindowLeftCNO") $defaultCNO;
  1488.                     }
  1489.  
  1490.                     if(`optionVar -exists ("connectWindowLeftSHD")` == 1) {
  1491.                         $defaultSHD = `optionVar -q ("connectWindowLeftSHD")`;
  1492.                     } else {
  1493.                         optionVar -iv ("connectWindowLeftSHD") $defaultSHD;
  1494.                     }
  1495.  
  1496.  
  1497.                     $leftWin = `nodeOutliner -showOutputs true     //configured for inputs
  1498.                                  -addCommand "connectWindowSetLeftLabel %node"
  1499.                                  -showNonConnectable false  // like it says
  1500.                                  -showConnectedOnly $defaultCNO  // like it says
  1501.                                  -showNonKeyable $defaultSNK // like it says
  1502.                                  -showHidden  $defaultSHD // like it says
  1503.                                  -ms 0             //multiple select disallowed
  1504.                                  leftSideCW`;
  1505.  
  1506.                     nodeOutliner -e 
  1507.                         -menuCommand ("CWpopupMenuCB " + $leftWin)
  1508.                     $leftWin;
  1509.  
  1510.                     // get some value defaults for the left side nodeOutliner.
  1511.                     //
  1512.                     $defaultSNK = true;
  1513.                     $defaultCNO = false;
  1514.                     $defaultSHD = false;
  1515.  
  1516.                     if(`optionVar -exists ("connectWindowRightSNK")` == 1) {
  1517.                         $defaultSNK = `optionVar -q ("connectWindowRightSNK")`;
  1518.                     } else {
  1519.                         optionVar -iv ("connectWindowRightSNK") $defaultSNK;
  1520.                     }
  1521.  
  1522.                     if(`optionVar -exists ("connectWindowRightCNO")` == 1) {
  1523.                         $defaultCNO = `optionVar -q ("connectWindowRightCNO")`;
  1524.                     } else {
  1525.                         optionVar -iv ("connectWindowRightCNO") $defaultCNO;
  1526.                     }
  1527.  
  1528.                     if(`optionVar -exists ("connectWindowRightSHD")` == 1) {
  1529.                         $defaultSHD = `optionVar -q ("connectWindowRightSHD")`;
  1530.                     } else {
  1531.                         optionVar -iv ("connectWindowRightSHD") $defaultSHD;
  1532.                     }
  1533.  
  1534.                     $rightWin = `nodeOutliner -showInputs true     //configured for inputs
  1535.                                  -addCommand "connectWindowSetRightLabel %node"
  1536.                                  -showNonConnectable false // like it says
  1537.                                  -showConnectedOnly $defaultCNO  // like it says
  1538.                                  -showNonKeyable $defaultSNK // like it says
  1539.                                  -showHidden  $defaultSHD // like it says
  1540.                                  -ms true             //multiple select allowed
  1541.                                  rightSideCW`;
  1542.  
  1543.                     nodeOutliner -e 
  1544.                         -menuCommand ("CWpopupMenuCB " + $rightWin)
  1545.                         $rightWin;
  1546.  
  1547.                     int $leftToRight = 1;
  1548.                     string $leftLabel, $rightLabel;
  1549.                     
  1550.                     if(`optionVar -exists "connectWindowLeftToRight"` == 1) {
  1551.                         $leftToRight = `optionVar -q "connectWindowLeftToRight"`;
  1552.                     } else {
  1553.                         optionVar -iv "connectWindowLeftToRight" $leftToRight;
  1554.                     }
  1555.  
  1556.                     if($leftToRight == 1) {
  1557.                         // just need to set commands
  1558.                         button -e -l "from -> to" $switchBut;                        
  1559.                         nodeOutliner -e 
  1560.                             -selectCommand ("nodeOutlinerOutputsCmd " + $leftWin + " " + $rightWin )
  1561.                         $leftWin;
  1562.  
  1563.                         nodeOutliner -e -pressHighlightsUnconnected false -selectCommand 
  1564.                             ("nodeOutlinerInputsCmd " + $leftWin + " " + $rightWin +
  1565.                             "; nodeOutliner -e -r " + $rightWin)
  1566.                         $rightWin;
  1567.  
  1568.                         $leftLabel = "Outputs";
  1569.                         $rightLabel = "Inputs";
  1570.                     } else {
  1571.                         // need to reconfigure the listers as well as set the commands
  1572.                         text -e -label "Outputs" $inputText;
  1573.                         text -e -label "Inputs" $outputText;
  1574.                         button -e -l "to <- from" $switchBut;
  1575.  
  1576.                         nodeOutliner -e -showInputs false -showOutputs true
  1577.                             -selectCommand ("nodeOutlinerOutputsCmd " + $rightWin + " " + $leftWin)
  1578.                             $rightWin;
  1579.                         nodeOutliner -e -pressHighlightsUnconnected false -showInputs true 
  1580.                             -showOutputs false -selectCommand 
  1581.                             ("nodeOutlinerInputsCmd " + $rightWin + " " + $leftWin + 
  1582.                             "; nodeOutliner -e -r " + $leftWin )
  1583.                             $leftWin;
  1584.  
  1585.                         $leftLabel = "Inputs";
  1586.                         $rightLabel = "Outputs";
  1587.                     }
  1588.                     
  1589.                 setParent ..;
  1590.                     
  1591.                 string $labelForm2 = `formLayout labelForm2`;
  1592.                     global string $connectWinRightLabel;
  1593.                     $connectWinRightLabel 
  1594.                         = `text -l $rightLabel -p $labelForm2 -al "center" connectWinRightLabel`;
  1595.                     
  1596.                     global string $connectWinLeftLabel;
  1597.                     $connectWinLeftLabel 
  1598.                         = `text -l $leftLabel -p $labelForm2 -al "center" connectWinLeftLabel`;
  1599.  
  1600.                     // page left/right buttons
  1601.                      string $buttonName = `button -l "<" -p $labelForm2 
  1602.                                          -ann "Move Right Side into Left and load a Right connection into Right" 
  1603.                                          pageLeft`;
  1604.                      string $buttonName2 = `button -l ">" -p $labelForm2 
  1605.                                           -ann "Move Left Side into Right and load a Left connection into Left" 
  1606.                                           pageRight`;
  1607.                     // menus for the button
  1608.                     string $menuName = `popupMenu -parent pageLeft leftPropagateMenu`;
  1609.                     string $menuName2 = `popupMenu -parent pageRight rightPropagateMenu`;
  1610.  
  1611.                     popupMenu -e -postMenuCommand 
  1612.                         ("CWpropagateMenu -left " + $menuName + " " + $menuName2 ) 
  1613.                         $menuName;
  1614.                     button -e -c 
  1615.                         ("CWpropagateButtonCB -left " + $menuName + " " + $menuName2 ) 
  1616.                         $buttonName;
  1617.                     popupMenu -e -postMenuCommand 
  1618.                         ("CWpropagateMenu -right " + $menuName2 + " " + $menuName ) 
  1619.                         $menuName2;
  1620.                     button -e -c 
  1621.                         ("CWpropagateButtonCB -right " + $menuName2 + " " + $menuName ) 
  1622.                         $buttonName2;
  1623.  
  1624.                     separator -style "in" buttonSep;
  1625.  
  1626.                 setParent ..;
  1627.     
  1628.                  formLayout -e 
  1629.        
  1630.                      -af buttonSep "left" 0
  1631.                      -af buttonSep "right" 0
  1632.                      -af buttonSep "bottom" 5
  1633.  
  1634.                      -af connectWinLeftLabel "top" 1
  1635.                      -af connectWinLeftLabel "bottom" 8
  1636.                     -ap connectWinLeftLabel "left" -50 25
  1637.  
  1638.                     -an pageRight "top" 
  1639.                     -af pageRight "bottom" 8
  1640.                     -ap pageRight "left" 0 50
  1641.                     -ap pageRight "right" 0 54
  1642.        
  1643.                     -an pageLeft "top" 
  1644.                     -af pageLeft "bottom" 8
  1645.                     -ap pageLeft "left" 0 45
  1646.                     -ap pageLeft "right" 0 49
  1647.  
  1648.                     -af connectWinRightLabel "top" 1
  1649.                     -af connectWinRightLabel "bottom" 8
  1650.                     -ap connectWinRightLabel "right" -50 75
  1651.  
  1652.                  $labelForm2;
  1653.  
  1654.                    // and four more buttons at the bottom
  1655.                    button -l "Clear All" -p $aForm 
  1656.                     -ann "Remove everything from Connection Editor"
  1657.                     -c "connectWindowClearCmd" clear;
  1658.                    button -l "Remove" -p $aForm 
  1659.                     -ann "Remove highlighted objects (if attributes highlighted, removes their object)"
  1660.                     -c "connectWindowRemoveCmd" nuke;
  1661.                    button -l "Break" -p $aForm -enable $modal 
  1662.                     -ann "Break highlighed connections"
  1663.                     -c "connectWindowBreakCmd" dis;
  1664.                    button -l "Make" -p $aForm -enable $modal
  1665.                     -ann "Connect highlighed attributes"
  1666.                     -c "connectWindowMakeCmd" con;
  1667.                    button -l "Close" -p $aForm 
  1668.                     -ann "Close Connection Editor"
  1669.                     -c "deleteUI connectWindow" closeBtn;
  1670.  
  1671.             setParent ..;
  1672.         setParent ..;
  1673.  
  1674.         // set the attachments
  1675.         int $active = 0;
  1676.                 
  1677.         if(`optionVar -exists "connectWindowActive"` == 1) {
  1678.             $active = `optionVar -q "connectWindowActive"`;
  1679.         } else {
  1680.             optionVar -iv "connectWindowActive" $active;
  1681.         }
  1682.  
  1683.         formLayout -e 
  1684.               -af fillLeft "top" 1
  1685.               -ap fillLeft "right" 0 49
  1686.               -af fillLeft "left" 1
  1687.  
  1688.               -af fillRight "top" 1
  1689.               -ap fillRight "left" 0 49
  1690.               -af fillRight "right" 1
  1691.  
  1692.              -ac labelForm "top" 1 fillLeft
  1693.              -af labelForm "left" 1
  1694.              -af labelForm "right" 1
  1695.  
  1696.              -ac connectWindowPane "top" 1 labelForm
  1697.              -af connectWindowPane "left" 1
  1698.              -af connectWindowPane "right" 1
  1699.              -ac connectWindowPane "bottom" 0 labelForm2
  1700.  
  1701.              -an labelForm2 "top" 
  1702.              -af labelForm2 "left" 1
  1703.              -af labelForm2 "right" 1
  1704.             -ac labelForm2 "bottom" 0 clear
  1705.  
  1706.             -an clear "top"
  1707.              -af clear "left" 5
  1708.              -ap clear "right" 3 20
  1709.             -af clear "bottom" 5
  1710.  
  1711.             -an nuke "top"
  1712.              -ap nuke "left" 2 20 
  1713.              -ap nuke "right" 3 40
  1714.             -af nuke "bottom" 5
  1715.  
  1716.             -an dis "top"
  1717.             -ap dis "left" 3 40
  1718.             -ap dis "right" 2 60
  1719.             -af dis "bottom" 5
  1720.  
  1721.             -an con "top"
  1722.             -ap con "left" 2 60
  1723.             -ap con "right" 3 80
  1724.             -af con "bottom" 5
  1725.  
  1726.             -an closeBtn "top"
  1727.             -ap closeBtn "left" 2 80
  1728.             -af closeBtn "right" 5
  1729.             -af closeBtn "bottom" 5
  1730.         $aForm;
  1731.         
  1732.         buildConnectWindowMenu;
  1733.  
  1734.         showWindow connectWindow;
  1735.  
  1736.         // restore the parent window so next controls made
  1737.         // don't get added to the connect Window
  1738.         //
  1739.         setParent ..;
  1740.     }
  1741. }
  1742.